laravel conditional class

44

laravel conditional class -

<li class="nav-item {{ request()->is('blog') ? 'active' : ''}}">
    <a class="nav-link " href="{{ url('blog') }}">{{ __('sentence.Blog') }}</a>
</li>

laravel blade conditional class -

@php
    $isActive = false;
    $hasError = true;
@endphp
 
<span @class([
    'p-4',
    'font-bold' => $isActive,
    'text-gray-500' => ! $isActive,
    'bg-red' => $hasError,
])></span>
 
<span class="p-4 text-gray-500 bg-red"></span>

Comments

Submit
0 Comments